package com.goods.business.converter;

import com.goods.common.model.business.Product;
import com.goods.common.model.business.Supplier;
import com.goods.common.vo.business.ProductVO;
import com.goods.common.vo.business.SupplierVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Component
public class ProductConverter {

    /**
     * 转voList
     * @param
     * @return
     */
    public static List<ProductVO> converterToProductVOList(List<Product> products) {
        List<ProductVO> productVOS=new ArrayList<>();
        if(!CollectionUtils.isEmpty(products)){
            for (Product Product : products) {
                ProductVO productVO = new ProductVO();
                BeanUtils.copyProperties(Product,productVO);
                productVOS.add(productVO);
            }
        }
        return productVOS;
    }
    public static ProductVO converterToProductVO(Product product){
        ProductVO productVO = new ProductVO();
        BeanUtils.copyProperties(product,productVO);
        return productVO;
    }




}
